//
// Created by tracyhenry on 2022/7/18.
//

#ifndef DEVICE_FSK_H
#define DEVICE_FSK_H
#include <iostream>
#include "err.h"

using namespace std;

//Sub device status (including gateway status (if devicesubid is 0))
typedef enum {
    DEVICE_DELETE = -1,
    DEVICE_OFFLINE = 0,
    DEVICE_NORMAL = 1,
    DEVICE_LOW_BATTERY = 2,
    DEVICE_ALARM  = 3,
    DEVICE_FAULT  = 4,
    DEVICE_TEST_ALARM = 5,
    DEVICE_DOOR_OPEN = 6,
    DEVICE_DOOR_CLOSE = 7,
    DEVICE_DOOR_STILL_OPEN = 8,
    DEVICE_HAS_BEEN_MOVED = 9,
    DEVICE_HELP = 10,
    DEVICE_HAS_PEOPLE_MOVE = 11,
    DEVICE_SILENCE = 12,
    DEVICE_SMOKE_ALARM = 13,
    DEVICE_SMOKE_SILENCE = 14,
    DEVICE_SMOKE_FAULT = 15,
    DEVICE_TEMP_ALARM = 16,
    DEVICE_LIFE_STOP = 17,
    DEVICE_UNLOCK = 18,
    DEVICE_PASSWORD_UNLOCK = 19,
    DEVICE_CARD_UNLOCK = 20,
    DEVICE_FOOTPRINT_UNLOCK = 21,
    DEVICE_ILLEGAL_OPERATION = 22,
    DEVICE_COERCION = 23,
    DEVICE_ACTIVED = 24,
    DEVICE_PASSWORD_ERROR = 25,
    DEVICE_SOCKET_OPEN = 26,
    DEVICE_SOCKET_CLOSE = 27,
    DEVICE_GS585_TRIGGER = 28,  //GS585 Press the key
    DEVICE_GS584_HOME_MODE_TRIGGER = 29,  //GS584 Press Home mode
    DEVICE_GS584_AWAY_MODE_TRIGGER = 30,  //GS584 Press Away mode
    DEVICE_GS584_SLEEP_MODE_TRIGGER = 31,  //GS584 Press Sleep mode
    DEVICE_GS584_OTHER_MODE_TRIGGER = 32,  //GS584 Press custom button
    DEVICE_CO_SENSOR_FAULT = 33, 
    DEVICE_GAS_SENSOR_FAULT = 34, 
    DEVICE_CO_ALARM = 35, 
    DEVICE_GAS_ALARM = 36,
    DEVICE_CO_SILENCE = 37,  
    DEVICE_GAS_SILENCE = 38,
    DEVICE_STOP_TURN = 39,  
    DEVICE_PRE_HEAT = 40, 
    GATEWAY_AC_ON = 41,
    GATEWAY_AC_OFF  = 42,
    GATEWAY_BATTERY_NORMAL  = 43,
    GATEWAY_BATTERY_LOW = 44,
    GATEWAY_LONG_TIME_NO_MOVE = 45,  //Not moved for a long time
    GATEWAY_OFF_LINE = 46, 
}Sub_Device_Status;


class GS870_Status
{
  public:
    int gas_concentration_half; //if or not 0.5
    int gas_concentration;
};


class GS240_Status
{
  public:
    int cur_temp; 
    int cur_humidity;
};


class GS241_Status
{
  public:
    int cur_temp_zheng;         //temp unit ℃
    int cur_temp_xiaoshu;       //0-9  temp unit ℃
    int cur_humidity_zheng;
    int cur_humidity_xiaoshu;   //0-9
    int cur_co_concentration; //ppm
    int message_type;             //0:all 1:only temp package 2:only humidity package 3:only co_concentration package
};

class GS361_Status
{
  public:
    int cur_temp;
    int cur_set_temp;       //  temp unit ℃
    int cur_set_temp_half;  //0.5  temp unit ℃
    int isValveCheckEnable;
    int isWindowCheckEnable;
    int isValveCheck;
    int isWindowCheck;
    int isChildLock;
    int mode ;  //0:fangdong mode 1:handler mode 2: auto mode other: install mode
};


class DeviceFsk
{
    private:
        void handlerDevStatus(string,string);
    public:
        DeviceFsk(string data1,string data2);
        Result result_err;    // 0 success,no 0 fail,
        int roomId;    // roomId -1 unknown, roomId 0 represents the default room, roomId 1-9 represents the room ID,
        int subId;     // subId
        int isAc;     // 0:DC 1:AC
        int rssid;    //rf signal intensity 0-4
        int battery;  // battery 0-100;
        string device_type; //device_type
        Sub_Device_Status device_status;
        GS240_Status * gs240_Status;
        GS241_Status * gs241_Status;
        GS361_Status * gs361_Status;
        GS870_Status * gs870_Status;
};

#endif //DEVICE_FSK_H
